package com.ssy.lingxi.platform.template.service.entity.door;

import com.ssy.lingxi.platform.template.service.handler.convert.JpaJsonToAreaBOConverter;
import com.ssy.lingxi.platform.template.service.handler.convert.JpaJsonToSlideshowConverter;
import com.ssy.lingxi.platform.template.service.handler.convert.JpaJsonToStringListConverter;
import com.ssy.lingxi.platform.template.service.model.bo.AreaBO;
import com.ssy.lingxi.platform.template.service.model.bo.SlideshowBO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 采购门户 - DO
 * @author fhj
 * @date 2021/04/14
 * @version 2.0.0
 */
@Data
@Entity
@Table(schema = "public", name = "pt_member_purchase", indexes = {
        @Index(name = "pt_member_purchase_member_id_idx", columnList = "memberId"),
        @Index(name = "pt_member_purchase_role_id_idx", columnList = "roleId")
})
public class MemberPurchase {

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_purchase_seq")
    @SequenceGenerator(sequenceName="pt_member_purchase_seq", name="member_purchase_seq", allocationSize = 1)
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "会员ID")
    private Long memberId;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "角色ID")
    private Long roleId;

    @Convert(converter = JpaJsonToAreaBOConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "地市")
    private List<AreaBO> areaBOList = new ArrayList<>();

    @Column(columnDefinition = "varchar(200)")
    @ApiModelProperty(value = "公司LOGO")
    private String logo;

    @Column(columnDefinition = "varchar(400)")
    @ApiModelProperty(value = "公司简介")
    private String describe;

    @Convert(converter = JpaJsonToSlideshowConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "首页轮播图")
    private List<SlideshowBO> slideshowBOList;

    @Convert(converter = JpaJsonToStringListConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "公司照片")
    private List<String> companyPics;

    @Convert(converter = JpaJsonToStringListConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "资质荣誉")
    private List<String> honorPics;

    @Convert(converter = JpaJsonToStringListConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "采购门户广告图")
    private List<String> advertPics;

    @Column(columnDefinition = "varchar(128)")
    @ApiModelProperty(value = "宣传画册名称")
    private String albumName;

    @Column(columnDefinition = "varchar(200)")
    @ApiModelProperty(value = "宣传画册地址")
    private String albumUrl;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "创建时间")
    private Long createTime = System.currentTimeMillis();

    @Column(columnDefinition = "varchar(500)")
    @ApiModelProperty(value = "地市（冗余）")
    private String areas;

    @Column(columnDefinition = "text")
    @ApiModelProperty(value = "省编码（冗余）")
    private String provincesCodeList;

    @Column(columnDefinition = "text")
    @ApiModelProperty(value = "市编码（冗余）")
    private String cityCodeList;

    @Column(columnDefinition = "varchar(200)")
    @ApiModelProperty(value = "会员名称（冗余）")
    private String memberName;

    @Column(columnDefinition = "varchar(64)")
    @ApiModelProperty(value = "会员等级名称（冗余）")
    private String levelTag;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "注册年数（冗余）")
    private Integer registerYears;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "信用积分（冗余）")
    private Integer creditPoint = 0;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "满意度（冗余）")
    private Integer avgTradeCommentStar = 5;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "状态：0-冻结 1-正常（冗余）")
    private Integer status = 1;

    @Column(columnDefinition = "varchar(128)")
    @ApiModelProperty(value = "注册资本（冗余）")
    private String registeredCapital;

    @Column(columnDefinition = "varchar(128)")
    @ApiModelProperty(value = "成立日期（冗余）")
    private String establishmentDate;

    @Column(columnDefinition = "varchar(500)")
    @ApiModelProperty(value = "营业执照（冗余）")
    private String businessLicence;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "注册地址（省、市、区）（冗余）")
    private String registerArea;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "注册地址（详细地址）（冗余）")
    private String registerAddress;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "注册地址（省名称）（冗余）")
    private String provinceName;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "注册地址（市名称）（冗余）")
    private String cityName;
}
